package com.example.figurehecheng.controller.merchant;

import com.example.figurehecheng.common.result.Result;
import com.example.figurehecheng.domain.dto.SceneryCreateDTO;
import com.example.figurehecheng.domain.dto.SceneryUpdateDTO;
import com.example.figurehecheng.domain.vo.SceneryVO;
import com.example.figurehecheng.service.ISceneryService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 景点表 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-03-04
 */
@RestController("adminSceneryController")
@RequestMapping("/scenery")
@CrossOrigin
@RequiredArgsConstructor
public class SceneryController {

    @Autowired
    private ISceneryService sceneryService;

    @PostMapping("/create")
    @ApiOperation("创建景点")
    public Result<Long> createScenery(@RequestBody @Valid SceneryCreateDTO dto) {
        Long sceneryId = sceneryService.createScenery(dto);
        return Result.success(sceneryId);
    }
    
    @GetMapping("/list")
    @ApiOperation("获取商家景点列表")
    public Result<List<SceneryVO>> getSceneryList() {
        List<SceneryVO> list = sceneryService.getSceneryListByMid();
        return Result.success(list);
    }

    @GetMapping("/info")
    @ApiOperation("获取商家景点详情")
    public Result<SceneryVO> getSceneryInfo() {
        SceneryVO scenery = sceneryService.getSceneryByMid();
        return Result.success(scenery);
    }

    @PutMapping("/update")
    @ApiOperation("修改景点信息")
    public Result<Boolean> updateScenery(@RequestBody @Valid SceneryUpdateDTO dto) {
        boolean success = sceneryService.updateScenery(dto);
        return Result.success(success);
    }
}
